<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Code Igniter
 *
 * An open source application development framework for PHP 4.3.2 or newer
 *
 * @package		CodeIgniter
 * @author		Gabriel Popa
 * @copyright	Copyright (c) 2008, IELLO-DEV
 * @license		http://www.codeignitor.com/user_guide/license.html
 * @link		http://www.codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

class Ext_form_loading_array {
	
	function Ext_form_loading_array(){
		$this->CI =& get_instance();
		log_message('debug', "Ext form loading array library initialized");
		
	}
	function build($array){
		//log_message('debug', "For ExtJS form ARRAY: ".print_r($array, TRUE));
		
		$str ='{success:true, data:{';
		$i = 0;
		$j = 0;
			foreach ($array as $key => $value){
				if (is_array($value)) {
					foreach($value as $childKey => $childValue){
						$str .= $childKey.":'".$childValue."'";
						$i++;
						if($i != sizeof($value)){
							$str .= ",";
						}
					}
				} else {	
            		$str .= $key.":'".$value."'";
					$j++;
					if($j != sizeof($array)){
						$str .= ",";
					}
				}	
			}
			$str .="}}";
			return $str;
	}	
}

?>